package com.juc.phaser.phaser4;

import java.util.concurrent.Phaser;

public class ThreadA extends Thread {

	/**
	 * getPhase() 获取已经到达第几个屏障
	 */
	
	private Phaser phaser;
	
	public ThreadA(Phaser phaser){
		super();
		this.phaser =phaser;
	}
	@Override
	public void run() {
		System.out.println("A begin");
		phaser.arriveAndAwaitAdvance();
		System.out.println("A end phase value = " +phaser.getPhase());
		
		System.out.println("A begin");
		phaser.arriveAndAwaitAdvance();
		System.out.println("A end phase value = " +phaser.getPhase());
		
		System.out.println("A begin");
		phaser.arriveAndAwaitAdvance();
		System.out.println("A end phase value = " +phaser.getPhase());
		
		System.out.println("A begin");
		phaser.arriveAndAwaitAdvance();
		System.out.println("A end phase value = " +phaser.getPhase());
		
		
	}
}
